<?php
/*
 * form to datagrid page to display users
*/

//check for an admin session
include("../inc_files/utils/checkadmin.php");
//include the page header
include("../inc_files/ui/header.php");?>
<title>Users</title>
<script
	type="text/javascript" src="../scripts/async.js"></script>
<script type='text/javascript'>

//async refresh of users datagrid
function refreshgrid(){
	var nochache = Math.floor(Math.random() * 10000);
	getasync('a_listusers.php?&nocache=' +
			 nochache,'datagrid', true);		
}

function deleteuser(userid){
//confirm deletion with user
if(confirm("Are you sure you want to mark the user as deleted?"))
	{
		//create a new user then refresh the data grid with new data - user records are retained for audit/reporting purposes
		//just rendered disabled by adding a deleted flag
		alert(postasync('a_deleteuser.php','value','userid='+userid, false)+ " user marked as deleted");
		refreshgrid();
	}
}

</script>
</head>
<body>
	<?php

	//add the navigation to the page
	include("../inc_files/ui/menu.php");?>
	<!-- add a div tag to display the list of users using AJAX -->
	<div id="datagrid"></div>
	<?php
	//add the page footer
	include("../inc_files/ui/footer.php");?>
	<script type="text/javascript">	
	//populate the datagrid on page load
	refreshgrid();	
	</script>
</body>
</html>
